package com.flower.oss.adapter;

import com.flower.oss.entity.FileInfo;
import io.minio.errors.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.List;

/**
 * @author lavender
 * @version 1.0
 * @date 2024-07-11 18:32
 * 文件存储适配器
 */
public interface StorageAdapter {

    public void createBucket(String bucketName);

    /**
     * 上传文件
     * @param inputStream
     * @param bucket
     * @param objectName
     * @throws ServerException
     * @throws InsufficientDataException
     * @throws ErrorResponseException
     * @throws IOException
     * @throws NoSuchAlgorithmException
     * @throws InvalidKeyException
     * @throws InvalidResponseException
     * @throws XmlParserException
     * @throws InternalException
     */
     void uploadFile(MultipartFile inputStream, String bucket, String objectName);

    /**
     * 列出所有桶
     */
     List<String> getAllBuckets();

    /**
     * 列出当前桶及文件
     */
     List<FileInfo> getAllFile(String bucket);

    /**
     * 下载文件
     * @param bucket
     * @param objectName
     * @return
     */

     InputStream downLoad(String bucket, String objectName);


    /**
     * 删除桶
     * @param bucket
     * @param objectName
     * @return
     * @throws ServerException
     * @throws InsufficientDataException
     * @throws ErrorResponseException
     * @throws IOException
     * @throws NoSuchAlgorithmException
     * @throws InvalidKeyException
     * @throws InvalidResponseException
     * @throws XmlParserException
     * @throws InternalException
     */
     void deleteBucket(String bucket);
    /**
     * 删除文件
     */
      void deleteObject(String bucket,String objectName);
}
